/**
 * Authors:
 * Vladimír Matěna
 * Jan Skalický
 */
package inireader;

/**
 * Enum for element type. Stores data type used by element and property.
 */
public enum ElementType
{
	String,
	Enum,
	Boolean,
	Int,
	/**
	 * represented using Long
	 */
	UInt,
	/**
	 * represented using Double
	 */
	Float;

	/**
	 * Converts String to ElementType.
	 * @param elemType String to convert
	 * @return converted string to type
	 */
	public static ElementType convertFromString(String elemType)
	{
		String type = elemType.toLowerCase();

		if (type.matches("string"))
		{
			return ElementType.String;
		}
		else if (type.matches("enum"))
		{
			return ElementType.Enum;
		}
		else if (type.matches("boolean"))
		{
			return ElementType.Boolean;
		}
		else if (type.matches("int"))
		{
			return ElementType.Int;
		}
		else if (type.matches("uint"))
		{
			return ElementType.UInt;
		}
		else if (type.matches("float"))
		{
			return ElementType.Float;
		}
		else
		{
			throw new ElementTypeCastException(java.lang.String.format("Cannot convert %s to ElemType!", type));
		}
	}
}
